import bookList.BookList;
import user.Admin;
import user.Normal;
import user.User;

import java.util.Arrays;
import java.util.Scanner;

/**
 * The type Book manger.
 *
 * @author CY
 * @date 2022 /08/09 22:16
 */
public class BookManger {
    /**
     * The entry point of application.
     *
     * @param args the input arguments
     */
    public static void main(String[] args) {
        for (String arg : args) {
            System.out.println(arg);
        }
        BookList bookList = new BookList();
        System.out.println("请输入你的姓名：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        System.out.println("1.管理员；2.用户");
        int choice = sc.nextInt();
        if (choice == 1) {
            User user = new Admin(name);
            while (true) {
                int choices = user.menu();
                user.doOperations(bookList, choices);
            }
        } else {
            User user = new Normal("name");
            while (true) {
                int choices = user.menu();
                user.doOperations(bookList, choices);
            }
        }


//        if (choice == 1) {
//            User user = new Admin(name);
//            while (true) {
//                int choices = user.menu();
//                Admin user1 = (Admin) user;
//                if (user1.getOts().length - 1 >= choices) {
//                    user1.getOts()[choices].work(bookList);
//                } else {
//                    System.out.println("管理员" + user.getName() + "你好，你的操作非法!");
//                    System.out.println();
//                }
//            }
//
//        } else {
//            User user = new Normal(name);
//            while (true) {
//                int choices = user.menu();
//                Normal user2 = (Normal) user;
//                if (user2.getOts().length - 1 >= choices) {
//                    user2.getOts()[choices].work(bookList);
//                } else {
//                    System.out.println("亲爱的" + user.getName() + "用户，你的输入非法！");
//                    System.out.println();
//                }
//            }
//        }


    }
}
